home *** CD-ROM | disk | FTP | other *** search
- VERSION 5.00
- Begin VB.Form frmCheckbook
- BorderStyle = 1 'Fixed Single
- Caption = "Check"
- ClientHeight = 4020
- ClientLeft = 1095
- ClientTop = 1485
- ClientWidth = 7935
- ControlBox = 0 'False
- BeginProperty Font
- Name = "MS Sans Serif"
- Size = 8.25
- Charset = 0
- Weight = 700
- Underline = 0 'False
- Italic = 0 'False
- Strikethrough = 0 'False
- EndProperty
- LinkTopic = "Form1"
- MaxButton = 0 'False
- MinButton = 0 'False
- PaletteMode = 1 'UseZOrder
- ScaleHeight = 4020
- ScaleWidth = 7935
- Begin VB.CommandButton cmdPrint
- Caption = "&Print Report"
- Height = 495
- Left = 4320
- TabIndex = 15
- Top = 3360
- Width = 1575
- End
- Begin VB.CommandButton cmdQuit
- Caption = "&Quit"
- Height = 495
- Left = 6360
- TabIndex = 16
- Top = 3360
- Width = 1455
- End
- Begin VB.CommandButton cmdRecord
- Caption = "&Record This Check"
- Height = 495
- Left = 120
- TabIndex = 13
- Top = 3360
- Width = 2055
- End
- Begin VB.CommandButton cmdMode
- Caption = "&Switch to Deposits"
- Height = 495
- Left = 2280
- TabIndex = 14
- Top = 3360
- Width = 1935
- End
- Begin VB.PictureBox picBox
- Height = 2655
- Left = 120
- ScaleHeight = 2595
- ScaleWidth = 7635
- TabIndex = 0
- TabStop = 0 'False
- Top = 120
- Width = 7695
- Begin VB.TextBox txtDate
- Height = 285
- Left = 5760
- TabIndex = 4
- Top = 690
- Width = 1812
- End
- Begin VB.TextBox txtAmount
- Height = 285
- Left = 5760
- TabIndex = 8
- Top = 1320
- Width = 1812
- End
- Begin VB.TextBox txtMemo
- Height = 285
- Left = 840
- TabIndex = 10
- Top = 2010
- Width = 3852
- End
- Begin VB.TextBox txtToFrom
- Height = 285
- Left = 840
- TabIndex = 6
- Top = 1290
- Width = 3852
- End
- Begin VB.TextBox txtNum
- Alignment = 1 'Right Justify
- BorderStyle = 0 'None
- Height = 225
- Left = 6960
- TabIndex = 2
- Top = 210
- Width = 495
- End
- Begin VB.Label lblAmount
- BackStyle = 0 'Transparent
- Caption = "Amount $"
- Height = 252
- Left = 4920
- TabIndex = 7
- Top = 1320
- Width = 852
- End
- Begin VB.Label lblDate
- BackStyle = 0 'Transparent
- Caption = "Date"
- Height = 252
- Left = 5280
- TabIndex = 3
- Top = 720
- Width = 372
- End
- Begin VB.Label lblMemo
- BackStyle = 0 'Transparent
- Caption = "Memo"
- Height = 255
- Left = 240
- TabIndex = 9
- Top = 2040
- Width = 495
- End
- Begin VB.Label lblToFrom
- Alignment = 1 'Right Justify
- BackStyle = 0 'Transparent
- Caption = "Pay To"
- Height = 255
- Left = 120
- TabIndex = 5
- Top = 1320
- Width = 615
- End
- Begin VB.Label lblName
- BackStyle = 0 'Transparent
- Height = 195
- Left = 360
- TabIndex = 1
- Top = 240
- Width = 3255
- End
- End
- Begin VB.Label lblBalance
- BackStyle = 0 'Transparent
- Height = 255
- Left = 4320
- TabIndex = 12
- Top = 3000
- Width = 1575
- End
- Begin VB.Label lblcurbal
- Alignment = 1 'Right Justify
- Caption = "Current Balance"
- Height = 255
- Left = 2760
- TabIndex = 11
- Top = 3000
- Width = 1455
- End
- Attribute VB_Name = "frmCheckbook"
- Attribute VB_GlobalNameSpace = False
- Attribute VB_Creatable = False
- Attribute VB_PredeclaredId = True
- Attribute VB_Exposed = False
- Dim fileName As String 'Name of data file
- Dim nameOnChk As String 'Name to appear on checks
- Dim lastCkNum As Integer 'Number of last check written
- Dim lastDpNum As Integer 'Number of last deposit slip processed
- Dim curBal As Single 'Current balance in account
- Dim transType As String 'Type of transaction, check or deposit
- Private Function AllDataGiven() As Boolean
- Dim message As String
- 'If one of the four required pieces of information
- 'is missing, assign its name to message
- message = ""
- If txtDate.Text = "" Then
- message = "Date"
- txtDate.SetFocus
- ElseIf txtToFrom.Text = "" Then
- If transType = "Check" Then
- message = "Pay To"
- Else
- message = "Source"
- End If
- txtToFrom.SetFocus
- ElseIf txtAmount.Text = "" Then
- message = "Amount"
- txtAmount.SetFocus
- ElseIf txtNum.Text = "" Then
- If transType = "Check" Then
- message = "Check Number"
- Else
- message = "Deposit Number"
- End If
- txtNum.SetFocus
- End If
- If message = "" Then
- 'All required data fields have been filled; recording can proceed
- AllDataGiven = True
- Else
- 'Advise user of required data which is missing
- MsgBox "The '" & message & "' field must be filled", , "Error"
- AllDataGiven = False
- End If
- End Function
- Private Sub cmdMode_Click()
- 'Toggle from Check to/from Deposit Slip
- If transType = "Check" Then
- Call SetupDeposit
- Else 'transType = "Deposit"
- Call SetupCheck
- End If
- Call InitializeFields
- txtToFrom.SetFocus
- End Sub
- Private Sub cmdPrint_Click()
- Dim temp As String, lineNo As Integer
- Dim nameOnChk As String, balance As Single, ck As Integer, dp As Integer
- Dim toFrom As String, amount As String, memo As String, theDate As String
- 'Print out a detailed list of all transactions.
- temp = frmCheckbook.Caption 'Save the current form caption
- frmCheckbook.Caption = "Printing..." 'Set form caption to indicate printing
- lineNo = 1 'Line number being printed
- Open fileName For Input As #1 'Open the file
- Input #1, nameOnChk, balance, ck, dp 'Read in the file header
- 'Print the details of the individual transactions.
- Do Until EOF(1)
- If lineNo >= 57 Then
- '57 or more lines have been printed; start a new page
- Printer.NewPage
- lineNo = 1
- End If
- If lineNo = 1 Then
- 'Print the report header
- Printer.Print
- Printer.Print "Name: "; nameOnChk; Tab(65); FormatDateTime(Now, vbLongDate)
- Printer.Print
- Printer.Print , "Starting balance: "; FormatCurrency(balance)
- Printer.Print
- Printer.Print "Date", "Transaction"; Tab(50); "Amount";
- Printer.Print Tab(65); "Balance"
- Printer.Print "____", "___________"; Tab(50); "______";
- Printer.Print Tab(65); "_______"
- Printer.Print
- Printer.Print
- lineNo = 10
- End If
- Input #1, transType, toFrom, balance, ck, dp, amount, memo, theDate
- If transType = "Check" Then
- Printer.Print theDate, "Check #: "; ck; Tab(50); amount;
- Printer.Print Tab(65); FormatCurrency(balance)
- Printer.Print , "Payed to: "; toFrom
- Else 'Transaction was a deposit
- Printer.Print theDate, "Deposit #: "; dp; Tab(50); amount;
- Printer.Print Tab(65); FormatCurrency(balance)
- Printer.Print , "Source: "; toFrom
- End If
- lineNo = lineNo + 2
- 'If there was a memo, then print it.
- If memo <> "" Then
- Printer.Print , "Memo: "; memo
- lineNo = lineNo + 1
- End If
- Printer.Print
- lineNo = lineNo + 1
- Loop
- Close #1 'Close the file
- 'Print the ending balance
- Printer.Print
- Printer.Print , "Ending Balance: "; FormatCurrency(balance)
- Printer.EndDoc 'Send the output to the Printer
- frmCheckbook.Caption = temp 'Restore the form caption
- txtToFrom.SetFocus 'Set focus for the next entry
- End Sub
- Private Sub cmdQuit_Click()
- ' Exit the program
- End
- End Sub
- Private Sub cmdRecord_Click()
- Dim amt As String, amount As Single, itemNum As Integer
- 'Check to ensure all required fields are filled
- If AllDataGiven Then
- amt = txtAmount.Text 'Amount of transaction as string
- amount = Val(amt) 'Amount of transaction as number
- amt = FormatCurrency(amt)
- itemNum = Val(txtNum.Text)
- If transType = "Check" Then
- curBal = curBal - amount
- lastCkNum = itemNum
- Else 'TransType = "Deposit"
- curBal = curBal + amount
- lastDpNum = itemNum
- End If
- lblBalance.Caption = FormatCurrency(curBal)
- Open fileName For Append As #1
- Write #1, transType, txtToFrom.Text, curBal, lastCkNum, lastDpNum, amt, _
- txtMemo.Text, txtDate.Text
- Close #1
- Call InitializeFields
- txtToFrom.SetFocus
- End If
- End Sub
- Private Sub CreateDataFile()
- Dim startBal As Single, ckNum As Integer
- 'The first time the program is run, create a data file
- Open fileName For Output As #1
- nameOnChk = InputBox("Name to appear on checks:")
- startBal = Val(InputBox("Starting balance:"))
- ckNum = Val(InputBox("Number of the first check:"))
- lastCkNum = ckNum - 1 'Number of "last" check written
- ckNum = Val(InputBox("Number of the first deposit slip:"))
- lastDpNum = ckNum - 1 'Number of "last" deposit slip processed
- curBal = startBal 'Set current balance
- 'First record in data file records name to appear on checks
- 'plus initial data for account
- Write #1, nameOnChk, startBal, lastCkNum, lastDpNum
- Close #1
- End Sub
- Private Sub Form_Load()
- Dim today As String
- 'Dim drive As String
- 'If no data file exists, create one. Otherwise, open the
- 'data file and get the user's name, last used check and
- 'deposit slip numbers, and current balance.
- 'In next line adjust drive as necessary
- 'drive = "A:" 'Drive (or path) for data file
- fileName = App.Path & "\CHKBOOK.TXT" 'Program uses one data file
- If Dir(fileName) = "" Then
- 'Data file does not exist, so create it and obtain initial data
- Call CreateDataFile
- Else
- Call ReadDataFile
- End If
- 'Set name and balance labels
- lblName.Caption = nameOnChk
- lblBalance.Caption = FormatCurrency(curBal)
- 'Set the date field to the current date
- today = FormatDateTime(Now, vbLongDate)
- txtDate.Text = Mid(today, 2 + InStr(today, ","))
- Call SetupCheck 'Always start session with checks
- Call InitializeFields
- End Sub
- Private Sub InitializeFields()
- 'Initialize all text entry fields except date
- txtToFrom.Text = ""
- txtAmount.Text = ""
- txtMemo.Text = ""
- If transType = "Check" Then
- 'Set txtNum textbox reflect next check number
- txtNum.Text = Str(lastCkNum + 1)
- Else 'TransType = "Deposit"
- 'Make txtNum textbox reflect next deposit slip number
- txtNum.Text = Str(lastDpNum + 1)
- End If
- End Sub
- Private Sub ReadDataFile()
- Dim t As String, s As String, n As String, m As String, d As String
- 'Recover name to appear on checks, current balance,
- 'number of last check written, and number of last deposit slip processed
- Open fileName For Input As #1
- Input #1, nameOnChk, curBal, lastCkNum, lastDpNum
- Do Until EOF(1)
- 'Read to the end of the file to recover the current balance and the
- 'last values recorded for ckNum and dpNum.
- 't, s, n, m and d are dummy variables and are not used at this point
- Input #1, t, s, curBal, lastCkNum, lastDpNum, n, m, d
- Loop
- Close #1
- End Sub
- Private Sub SetupCheck()
- 'Prepare form for the entry of a check
- transType = "Check"
- frmCheckbook.Caption = "Check"
- lblToFrom.Caption = "Pay To"
- cmdRecord.Caption = "&Record This Check"
- cmdMode.Caption = "&Switch to Deposits"
- picBox.BackColor = vbCyan 'color of check is light turquoise blue
- txtNum.BackColor = vbCyan
- End Sub
- Private Sub SetupDeposit()
- 'Prepare form for the entry of a deposit
- transType = "Deposit"
- frmCheckbook.Caption = "Deposit Slip"
- lblToFrom.Caption = "Source"
- cmdRecord.Caption = "&Record This Deposit"
- cmdMode.Caption = "&Switch to Checks"
- picBox.BackColor = vbYellow 'color of deposit slip is yellow
- txtNum.BackColor = vbYellow
- End Sub
-